import * as types from '../types'
import {Tools} from "../../lib/tools";
import {getBankBranch} from '@/api'
import router from '@/router'
import { Indicator } from 'mint-ui';

const state = {
    branchInput: "",
    branchListData: [],
}

const getters = {}

const actions = {
    [types.GET_BANK_BRANCH]({state}) {
        Indicator.open();
        getBankBranch(
            {
                json: {
                    service: 'merBranchBankListForWx',
                    wxRequestDate: (new Date()).format("yyyyMMddhhmmss"),
                    'key': state.branchInput,
                }
            }).then(data => {
            state.branchListData=data.branchBankList
            // console.log(state.branchListData)
        })
    },
    getBranchCode({state,rootState},value){
        rootState.merchantAccount.branchListCode=value.code
        rootState.merchantAccount.BankAccountBank[0].choose=value.bankBranchName
        router.push('merchantAccount')
    }
}

const mutations = {
    getInputDataChange(state, value) {
        state.branchInput = value
    },

}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}